package com.hod.client.charge;

import com.google.gwt.core.client.GWT;
import com.google.gwt.gears.client.database.DatabaseException;
import com.google.gwt.gears.client.database.ResultSet;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.data.Record;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.FieldSet;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.Label;
import com.gwtext.client.widgets.form.NumberField;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.grid.AbstractSelectionModel;
import com.gwtext.client.widgets.grid.RowSelectionModel;
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
import com.hod.client.HOD;
import com.hod.client.backend.orm.client.GearsDataStore;
import com.hod.client.chargedescription.ChargeDescription;
import com.hod.client.chargedescription.ChargeDescriptionCRUD;
import com.hod.client.chargedescription.ChargeDescriptionGrid;
import com.hod.client.frontend.CRUD;
import com.hod.client.frontend.HODForm;
import com.hod.client.lodging.LodgingCRUD;

public class ChargeCRUD extends CRUD {

    
    
	@Override
	protected void buildPanelSearch() {
		// TODO Auto-generated method stub

	}

	@Override
	protected AbstractSelectionModel createSelectionModel() {
		// TODO Auto-generated method stub
		final RowSelectionModel sm = new RowSelectionModel(true);
        sm.addListener(new RowSelectionListenerAdapter() {
        	public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record) {
                  formPanel.updateDataControls(record);
            }
        });
        return sm;
	}

	@Override
	protected Widget formTabs() {
		// TODO Auto-generated method stub
		return null;
	}
	public ChargeCRUD() {
		ds = (GearsDataStore) GWT.create(Charge.class);
		gridPanel = new ChargeGrid(false,ds,true);				
	}

	public void setIdLodging(Integer idLodging) {
		((ChargeFormPanel)formPanel).setIdLodging(idLodging);
	}

	public void setIdChargeDescription(Integer idChargeDescription) {
		((ChargeFormPanel)formPanel).setIdChargeDescription(idChargeDescription);
	}

	@Override
	public HODForm createFormPanel() {
		// TODO Auto-generated method stub
		if (formPanel==null) formPanel = new ChargeFormPanel(ds);
		return formPanel;
	}
}
